<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highsecondary" content="no">
    <meta name="viewport" content="user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,width=device-width">

    <title>询价维护 -采方</title>
    <link href="../lib/fonts/material-icons.css?family=Material+Icons" rel="stylesheet">
    <link href="../lib/css/animate.min.css" rel="stylesheet">
    <link href="../lib/css/quasar.mat.rtl.min.css" rel="stylesheet" type="text/css">
    <style>
      [v-cloak] { display: none }
      .bdl-secondary-3 { border-left: 3px solid #26a69a }
      div.q-field-vertical .q-field-label+.q-field-content { padding-top: 0!important }
      .search-group-left { font-size: 13px; border: 1px solid #ccc; padding: 3px 6px!important; border-radius: 3px 0 0 3px; border-right: none }
      .search-group-right { font-size: 13px;border: 1px solid #ccc; padding: 3px 6px!important; border-radius: 0 3px 3px 0 }
      .ant-input { font-size: 13px;border: 1px solid #ccc; padding: 3px 6px!important; border-radius: 3px }
    </style>
  </head>
  <body>
    <div id="q-rfxPurAdd" v-cloak>
      <q-layout>
        <q-page-container>
          <q-tabs inverted color="primary" v-model="selectedTab" @select="">
            <q-tab slot="title" name="tab-1" label="基本信息"></q-tab>
            <q-tab :disable="disable" slot="title" name="tab-2" label="明细"></q-tab>
            <q-tab :disable="disable" slot="title" name="tab-3" label="附件"></q-tab>
            <q-tab :disable="disable" slot="title" name="tab-4" label="供应商"></q-tab>

            <q-tab-pane name="tab-1" class="q-pa-none">
              <q-card class="bg-white no-shadow full-width">
                <q-card-main class="q-px-md q-py-sm relative-position">
                  <div class=" row justify-start gutter-x-md gutter-y-sm">
                    <q-field 
                      label="询价主题"
                      orientation="vertical"
                      :error="$v.baseAddOrEditForm.title.$error"
                      error-label="该字段为必填项"
                      class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                      <q-input 
                        @blur="$v.baseAddOrEditForm.title.$touch"
                        v-model.trim="baseAddOrEditForm.title" ></q-input>
                    </q-field>
                    <q-field 
                      label="询价类型"
                      orientation="vertical"
                      :error="$v.baseAddOrEditForm.type.$error"
                      error-label="该字段为必填项"
                      class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                      <q-select 
                        :options="typeOptions"
                        @blur="$v.baseAddOrEditForm.type.$touch"
                        v-model="baseAddOrEditForm.type" ></q-select>
                    </q-field>
                    <q-field 
                      label="是否密封报价"
                      orientation="vertical"
                      :error="$v.baseAddOrEditForm.isSeal.$error"
                      error-label="该字段为必填项"
                      class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                      <q-select 
                        :options="isSealOptions"
                        @blur="$v.baseAddOrEditForm.isSeal.$touch"
                        v-model="baseAddOrEditForm.isSeal" ></q-select>
                    </q-field>
                    <q-field 
                      label="采购组织"
                      orientation="vertical"
                      :error="$v.baseAddOrEditForm.purOrgId.$error"
                      error-label="该字段为必填项"
                      class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                      <q-select 
                        :options="purOrgOptions"
                        @blur="$v.baseAddOrEditForm.purOrgId.$touch"
                        v-model="baseAddOrEditForm.purOrgId" ></q-select>
                    </q-field>
                    <q-field 
                      label="采购组"
                      orientation="vertical"
                      :error="$v.baseAddOrEditForm.purGroupId.$error"
                      error-label="该字段为必填项"
                      class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                      <q-select 
                        :options="purGroupOptions"
                        @blur="$v.baseAddOrEditForm.purGroupId.$touch"
                        v-model="baseAddOrEditForm.purGroupId" ></q-select>
                    </q-field>
                    <q-field 
                      label="采购执行人"
                      orientation="vertical"
                      :error="$v.baseAddOrEditForm.purExecutorId.$error"
                      error-label="该字段为必填项"
                      class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                      <h-select-table 
                        :value="baseAddOrEditForm.purExecutorId"
                        :label="purExecutorName" 
                        label-field="name"
                        value-field="id"
                        :search-options="searchOptions"
                        :readonly="true"
                        url="/manager/user/userData/getUserList"
                        :columns="personColumns"
                        selection="single"
                        @select="personChanged"
                      ></h-select-table>
                    </q-field>
                    <q-field 
                      label="是否需要报名"
                      orientation="vertical"
                      class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                      <q-select
                        :options="isOptions"
                        v-model="baseAddOrEditForm.isSignUp"
                        ></q-select>
                    </q-field>
                    <q-field 
                      v-if="baseAddOrEditForm.isSignUp == 1"
                      label="报名开始时间"
                      orientation="vertical"
                      :error="$v.baseAddOrEditForm.signUpStartTime.$error"
                      error-label="该字段为必填项"
                      class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                      <q-datetime 
                        type="datetime"
                        format="YYYY-MM-DD HH:mm:ss"
                        format-model="string"
                        :max="baseAddOrEditForm.signUpEndTime"
                        @blur="$v.baseAddOrEditForm.signUpStartTime.$touch"
                        v-model="baseAddOrEditForm.signUpStartTime" ></q-datetime>
                    </q-field>
                    <q-field 
                      v-if="baseAddOrEditForm.isSignUp == 1"
                      label="报名截止时间"
                      orientation="vertical"
                      :error="$v.baseAddOrEditForm.signUpEndTime.$error"
                      error-label="该字段为必填项"
                      class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                      <q-datetime 
                        type="datetime"
                        format="YYYY-MM-DD HH:mm:ss"
                        format-model="string"
                        :min="baseAddOrEditForm.signUpStartTime"
                        :max="baseAddOrEditForm.quoteStartTime"
                        @blur="$v.baseAddOrEditForm.signUpEndTime.$touch"
                        v-model="baseAddOrEditForm.signUpEndTime" ></q-datetime>
                    </q-field>
                    <q-field 
                      label="报价开始时间"
                      orientation="vertical"
                      :error="$v.baseAddOrEditForm.quoteStartTime.$error"
                      error-label="该字段为必填项"
                      class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                      <q-datetime 
                        type="datetime"
                        format="YYYY-MM-DD HH:mm:ss"
                        format-model="string"
                        :min="baseAddOrEditForm.signUpEndTime"
                        :max="baseAddOrEditForm.quoteEndTime"
                        @blur="$v.baseAddOrEditForm.quoteStartTime.$touch"
                        v-model="baseAddOrEditForm.quoteStartTime" ></q-datetime>
                    </q-field>
                    <q-field 
                      label="报价截止时间"
                      orientation="vertical"
                      :error="$v.baseAddOrEditForm.quoteEndTime.$error"
                      error-label="该字段为必填项"
                      class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                      <q-datetime 
                        type="datetime"
                        format="YYYY-MM-DD HH:mm:ss"
                        format-model="string"
                        :min="baseAddOrEditForm.quoteStartTime"
                        @blur="$v.baseAddOrEditForm.quoteEndTime.$touch"
                        v-model="baseAddOrEditForm.quoteEndTime" ></q-datetime>
                    </q-field>
                    <q-field 
                      label="报价允许修改次数"
                      orientation="vertical"
                      :error="$v.baseAddOrEditForm.quoteModifyTimes.$error"
                      :error-label="$v.baseAddOrEditForm.quoteModifyTimes.required? '请输入数字': '该字段为必填项'"
                      class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                      <q-input 
                        @blur="$v.baseAddOrEditForm.quoteModifyTimes.$touch"
                        v-model.trim="baseAddOrEditForm.quoteModifyTimes" ></q-input>
                    </q-field>
                    <q-field 
                      label="是否需要TR评审"
                      orientation="vertical"
                      class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                      <q-select
                      :options="isOptions"
                      v-model="baseAddOrEditForm.isTr"
                      ></q-select>
                    </q-field>
                    <q-field 
                      v-if="baseAddOrEditForm.isTr == 1"
                      label="TR文件"
                      orientation="vertical"
                      :error="$v.baseAddOrEditForm.trFileId.$error"
                      error-label="该字段为必填项"
                      class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                      <q-uploader 
                        ref="trUploader"
                        color="secondary" 
                        name="files"
                        @uploaded="trUploaded"
                        :headers="{'Accept': 'application/json;charset=utf-8'}"
                        :url="uploadUrl+'TR_TEMPLATE'" ></q-uploader>
                    </q-field>
                    <q-field 
                      label="报价说明"
                      orientation="vertical"
                      class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                      <q-input
                        hide-underline
                        type="textarea"
                        rows="5"
                        style="border: 1px solid #ccc"
                        v-model="baseAddOrEditForm.remark"></q-input>
                    </q-field>
                  </div>
                  <div class="row q-mt-md">
                    <q-btn color="primary" push @click="baseInfoSave" :loading="btnLoading">保存</q-btn>
                    <div class="text-faded q-pt-sm q-ml-md" v-if="currentId == ''">
                      <q-icon name="help_outline" color="light" size="20px"></q-icon>
                      只有当您填写了基本信息并保存后，才能继续维护其它信息。
                    </div>
                  </div>
                  <q-inner-loading :visible="visible">
                    <q-spinner-gears size="50px" color="primary"></q-spinner-gears>
                  </q-inner-loading>
                </q-card-main>
              </q-card>
            </q-tab-pane>
            <q-tab-pane name="tab-2" class="q-pa-none q-mt-lg">
              <q-card class="bg-white no-shadow full-width">
                <q-card-main class="q-px-md q-py-sm relative-position">
                  <div class="row justify-between">
                    <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                      <q-btn
                        color="primary"
                        outline
                        size="xs"
                        label="新增"
                        @click="detailsModalOpen(1)"
                        class="q-mr-sm" ></q-btn>
                      <q-btn
                        color="negative"
                        outline
                        size="xs"
                        label="删除"
                        @click="detailsDel"
                        class="q-mr-sm"></q-btn>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 row justify-end">
                      <q-input 
                        class="search-group-left"
                        hide-underline
                        placeholder="输入名称、编码"
                        v-model.trim="searchForm.value"></q-input>
                      <q-select 
                        class="search-group-right"
                        hide-underline
                        radio
                        :options="[{ label:'名称', value: 'matName' }, { label:'编码', value: 'matCode' }]"
                        v-model="searchForm.key"></q-select>
                      <q-btn
                        size="sm"
                        color="primary"
                        :loading="btnLoadingSearch"
                        @click="searchDetails"
                        class="q-ml-sm q-pa-sm">
                        <span slot="loading">
                          <q-spinner-hourglass></q-spinner-hourglass>
                          搜索中
                        </span>
                        <q-icon name="search"></q-icon>
                        <span>{{ $t('查询') }}</span>
                      </q-btn>
                      <q-btn
                        size="sm"
                        color="secondary"
                        @click="resetDetails"
                        :loading="btnLoadingReset"
                        class="q-ml-sm q-pa-sm">
                        <span slot="loading">
                          <q-spinner-hourglass></q-spinner-hourglass>
                          重置中
                        </span>
                        <q-icon name="refresh" ></q-icon>
                        <span>{{ $t('重置') }}</span>
                      </q-btn>
                    </div>
                  </div>
                  <q-table
                    class="no-shadow"
                    :data="detailsTableData"
                    dense
                    hide-bottom
                    :columns="columns"
                    :rows-per-page-options="[5, 10, 20]"
                    selection="multiple"
                    :loading="listLoading"
                    :selected.sync="selected"
                    :pagination.sync="serverPagination"
                    @request="DetailsListGet"
                    row-key="id"
                  >
                    <template slot="body" slot-scope="props">
                      <q-tr
                        :props="props"
                      >
                        <q-td >
                          <q-checkbox color="primary" v-model="props.selected"></q-checkbox>
                        </q-td>
                        <q-td key="action" :props="props" >
                          <q-btn
                            flat
                            size="xs"
                            color="primary"
                            @click="detailsModalOpen(2, props.row)"
                            class="q-pa-xs"
                          >
                            修改
                          </q-btn>
                        </q-td>
                        <q-td key="matName" :props="props" >
                          {{ props.row.matName }}
                        </q-td>
                        <q-td key="matCode" :props="props" >
                          {{ props.row.matCode }}
                        </q-td>
                        <q-td key="matCategoryName" :props="props" >
                          {{ props.row.matCategoryName }}
                        </q-td>
                        <q-td key="carSeriesName" :props="props" >
                          {{ props.row.carSeriesName }}
                        </q-td>
                        <q-td key="quantity" :props="props" >
                          {{ props.row.quantity }}
                        </q-td>
                        <q-td key="unitName" :props="props" >
                          {{ props.row.unitName }}
                        </q-td>
                        <q-td key="carQuantity" :props="props" >
                          {{ props.row.carQuantity }}
                        </q-td>
                        <q-td key="currencyName" :props="props" >
                          {{ props.row.currencyName }}
                        </q-td>
                        <q-td key="quoteTempName" :props="props" >
                          {{ props.row.quoteTempName }}
                        </q-td>
                        <q-td key="targetPrice" :props="props" >
                          {{ props.row.targetPrice }}
                        </q-td>
                        <q-td key="adjustPrice" :props="props" >
                          {{ props.row.adjustPrice }}
                        </q-td>
                        <q-td key="isMoldCostShare" :props="props" >
                          <q-chip v-if="props.row.isMoldCostShare == 1" dense square color="positive">是</q-chip>
                          <q-chip v-if="props.row.isMoldCostShare == 0" dense square color="light">否</q-chip>
                        </q-td>
                        <q-td key="sorCode" :props="props" >
                          {{ props.row.sorCode }}
                        </q-td>
                        <q-td key="projectCode" :props="props" >
                          {{ props.row.projectCode }}
                        </q-td>
                        <q-td key="proposerName" :props="props" >
                          {{ props.row.proposerName }}
                        </q-td>
                        <q-td key="requiredFinishTime" :props="props" >
                          {{ props.row.requiredFinishTime }}
                        </q-td>
                        <q-td key="productLineName" :props="props" >
                          {{ props.row.productLineName }}
                        </q-td>
                        <q-td key="shareType" :props="props" >
                          <q-chip v-if="props.row.isMoldCostShare == 1" dense square color="info">一次性成本摊销</q-chip>
                          <q-chip v-if="props.row.isMoldCostShare == 2" dense square color="info">基于时间摊销</q-chip>
                          <q-chip v-if="props.row.isMoldCostShare == 3" dense square color="info">基于数量摊销</q-chip>
                        </q-td>
                        <q-td key="shareQuantity" :props="props" >
                          {{ props.row.shareQuantity + props.row.shareUnitName }}
                        </q-td>
                        <q-td key="sharePaymentTime" :props="props" >
                          {{ props.row.sharePaymentTime }}
                        </q-td>
                      </q-tr>
                      <q-tr v-show="props.expand" :props="props">
                        <q-td colspan="100%">
                          审核原因：{{ props.row.approveReason }}
                        </q-td>
                      </q-tr>
                    </template>
                  </q-table>
                  <div class="row justify-end items-center text-faded">
                    每页的行数：
                    <q-select 
                      :options="[{label: '5', value: 5},{label: '10', value: 10},{label: '20', value: 20}]" 
                      hide-underline
                      class="q-mr-md"
                      v-model="serverPagination.rowsPerPage"></q-select>
                    第
                    <q-pagination
                      class="q-mt-xs"
                      v-model="serverPagination.page"
                      input
                      boundary-links
                      direction-links
                      :max-pages="5"
                      :ellipses="true"
                      :max="pages"></q-pagination>
                    页 &nbsp; 共 {{ total }} 条
                  </div>
                  <q-inner-loading :visible="visible">
                    <q-spinner-gears size="50px" color="primary"></q-spinner-gears>
                  </q-inner-loading>
                </q-card-main>
              </q-card>
            </q-tab-pane>
            <q-tab-pane name="tab-3" class="q-pa-none q-mt-lg">
              <q-card class="bg-white no-shadow full-width">
                <q-card-main class="q-px-md q-py-sm relative-position">
                  <div class="row justify-between">
                    <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                      <q-btn
                        color="primary"
                        outline
                        size="xs"
                        label="新增"
                        @click="fileModalOpen(1)"
                        class="q-mr-sm" ></q-btn>
                      <q-btn
                        color="negative"
                        outline
                        size="xs"
                        label="删除"
                        @click="fileDel"
                        class="q-mr-sm"></q-btn>
                    </div>
                  </div>
                  <q-table
                    class="no-shadow"
                    :data="fileTableData"
                    dense
                    hide-bottom
                    :columns="fileColumns"
                    :rows-per-page-options="[5, 10, 20]"
                    selection="multiple"
                    :loading="listLoading"
                    :selected.sync="selectedFile"
                    :pagination.sync="serverPaginationFile"
                    @request="fileListGet"
                    row-key="id"
                  >
                    <template slot="body" slot-scope="props">
                      <q-tr
                        :props="props"
                      >
                        <q-td >
                          <q-checkbox color="primary" v-model="props.selected"></q-checkbox>
                        </q-td>
                        <q-td key="action" :props="props" >
                          <q-btn
                            flat
                            size="xs"
                            color="primary"
                            @click="fileModalOpen(2, props.row)"
                            class="q-pa-xs"
                          >
                            修改
                          </q-btn>
                        </q-td>
                        <q-td key="fileName" :props="props" >
                          {{ props.row.fileName }}
                        </q-td>
                        <q-td key="suffix" :props="props" >
                          {{ props.row.suffix }}
                        </q-td>
                        <q-td key="updateUserName" :props="props" >
                          {{ props.row.updateUserName }}
                        </q-td>
                        <q-td key="lastUpdateTime" :props="props" >
                          {{ props.row.lastUpdateTime }}
                        </q-td>
                        <q-td key="remark" :props="props" >
                          {{ props.row.remark }}
                        </q-td>
                      </q-tr>
                    </template>
                  </q-table>
                  <div class="row justify-end items-center text-faded">
                    每页的行数：
                    <q-select 
                      :options="[{label: '5', value: 5},{label: '10', value: 10},{label: '20', value: 20}]" 
                      hide-underline
                      class="q-mr-md"
                      v-model="serverPaginationFile.rowsPerPage"></q-select>
                    第
                    <q-pagination
                      class="q-mt-xs"
                      v-model="serverPaginationFile.page"
                      input
                      boundary-links
                      direction-links
                      :max-pages="5"
                      :ellipses="true"
                      :max="pagesFile"></q-pagination>
                    页 &nbsp; 共 {{ totalFile }} 条
                  </div>
                  <q-inner-loading :visible="visible">
                    <q-spinner-gears size="50px" color="primary"></q-spinner-gears>
                  </q-inner-loading>
                </q-card-main>
              </q-card>
            </q-tab-pane>
            <q-tab-pane name="tab-4" class="q-pa-none q-mt-lg">
              <q-card class="bg-white no-shadow full-width">
                <q-card-main class="q-px-md q-py-sm relative-position">
                  <div class="row justify-between">
                    <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                      <q-btn
                        color="primary"
                        outline
                        size="xs"
                        label="新增"
                        @click="supModalOpen(1)"
                        class="q-mr-sm" ></q-btn>
                      <q-btn
                        color="primary"
                        outline
                        size="xs"
                        label="PSA查询"
                        @click="psaSearch"
                        class="q-mr-sm" ></q-btn>
                      <q-btn
                        color="primary"
                        outline
                        size="xs"
                        label="邀请注册"
                        @click="window.location.href = '../pages/supplier.html'"
                        class="q-mr-sm"></q-btn>
                      <q-btn
                        color="negative"
                        outline
                        size="xs"
                        label="删除"
                        @click="supDel"
                        class="q-mr-sm"></q-btn>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 row justify-end">
                      <q-input 
                        class="search-group-left"
                        hide-underline
                        placeholder="输入名称、编号"
                        v-model.trim="searchFormSup.value"></q-input>
                      <q-select 
                        class="search-group-right"
                        hide-underline
                        radio
                        :options="[{ label:'名称', value: 'supplierName' }, { label:'编码', value: 'supplierCode' }]"
                        v-model="searchFormSup.key"></q-select>
                      <q-btn
                        size="sm"
                        color="primary"
                        :loading="btnLoadingSearch"
                        @click="searchSup"
                        class="q-ml-sm q-pa-sm">
                        <span slot="loading">
                          <q-spinner-hourglass></q-spinner-hourglass>
                          搜索中
                        </span>
                        <q-icon name="search"></q-icon>
                        <span>{{ $t('查询') }}</span>
                      </q-btn>
                      <q-btn
                        size="sm"
                        color="secondary"
                        @click="resetSup"
                        :loading="btnLoadingReset"
                        class="q-ml-sm q-pa-sm">
                        <span slot="loading">
                          <q-spinner-hourglass></q-spinner-hourglass>
                          重置中
                        </span>
                        <q-icon name="refresh" ></q-icon>
                        <span>{{ $t('重置') }}</span>
                      </q-btn>
                    </div>
                  </div>
                  <q-table
                    class="no-shadow"
                    :data="supTableData"
                    dense
                    hide-bottom
                    :columns="supColumns"
                    :rows-per-page-options="[5, 10, 20]"
                    selection="multiple"
                    :loading="listLoading"
                    :selected.sync="selectedSup"
                    :pagination.sync="serverPaginationSup"
                    @request="supListGet"
                    row-key="id"
                  >
                    <template slot="body" slot-scope="props">
                      <q-tr
                        :props="props"
                      >
                        <q-td >
                          <q-checkbox color="primary" v-model="props.selected"></q-checkbox>
                        </q-td>
                        <q-td key="action" :props="props" >
                          <q-btn
                            flat
                            size="xs"
                            color="primary"
                            @click="supModalOpen(2, props.row)"
                            class="q-pa-xs"
                          >
                            修改
                          </q-btn>
                        </q-td>
                        <q-td key="supplierCode" :props="props" >
                          {{ props.row.supplierCode }}
                        </q-td>
                        <q-td key="supplierName" :props="props" >
                          {{ props.row.supplierName }}
                        </q-td>
                        <q-td key="supplierStep" :props="props" >
                          {{ props.row.supplierStep }}
                          <!-- <q-chip v-if="props.row.supplierStep == 1" dense square color="positive">正式</q-chip>
                          <q-chip v-if="props.row.supplierStep == 2" dense square color="light">潜在</q-chip> -->
                        </q-td>
                        <q-td key="remark" :props="props" >
                          {{ props.row.remark }}
                        </q-td>
                      </q-tr>
                    </template>
                  </q-table>
                  <div class="row justify-end items-center text-faded">
                    每页的行数：
                    <q-select 
                      :options="[{label: '5', value: 5},{label: '10', value: 10},{label: '20', value: 20}]" 
                      hide-underline
                      class="q-mr-md"
                      v-model="serverPaginationSup.rowsPerPage"></q-select>
                    第
                    <q-pagination
                      class="q-mt-xs"
                      v-model="serverPaginationSup.page"
                      input
                      boundary-links
                      direction-links
                      :max-pages="5"
                      :ellipses="true"
                      :max="pagesSup"></q-pagination>
                    页 &nbsp; 共 {{ totalSup }} 条
                  </div>
                  <q-inner-loading :visible="visible">
                    <q-spinner-gears size="50px" color="primary"></q-spinner-gears>
                  </q-inner-loading>
                </q-card-main>
              </q-card>
            </q-tab-pane>
          </q-tabs>
          <q-page-sticky position="top-right" :offset="[32,20]">
            <q-fab
              color="primary"
              icon="keyboard_arrow_down"
              direction="down"
            >
              <q-fab-action 
                v-if="baseAddOrEditForm.status == 0 && baseAddOrEditForm.isClose == 0"
                color="primary" 
                @click="activate"
                icon="send">
                <q-tooltip anchor="center left" self="center right" :offset="[10, 10]">激活</q-tooltip>
              </q-fab-action>
              <q-fab-action 
                color="secondary" 
                @click="window.location.href = 'rfxPurList.html'"
                icon="arrow_back">
                <q-tooltip anchor="center left" self="center right" :offset="[10, 10]">返回</q-tooltip>
              </q-fab-action>
            </q-fab>
          </q-page-sticky>
        </q-page-container>
      </q-layout>
      <!-- 明细 新增 or 编辑 -->
      <q-modal no-backdrop-dismiss v-model="detailsAddOrEditModal" :content-css="{minWidth: '77vw', minHeight: '550px',borderRadius: '4px'}">
        <q-modal-layout>
          <q-toolbar slot="header" color="white">
            <q-toolbar-title class="text-dark">
              <span>{{ detailsAddOrEdit == 1 ? $t("新增") : $t("编辑")  }}</span>
            </q-toolbar-title>
            <q-btn flat @click="detailsAddOrEditModal = false">
              <q-icon name="close" color="dark"></q-icon>
            </q-btn>
          </q-toolbar>
          <q-card class="q-px-md q-py-sm bg-white no-shadow full-width">
            <p class="q-mb-none bdl-secondary-3 q-py-xs q-px-sm">主信息</p>
            <q-card-main class="row gutter-x-md gutter-y-xs">
              <q-field 
                label="零件编码"
                orientation="vertical"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <h-select-table 
                  :value="rowAddOrEditForm.matId" 
                  :label="rowAddOrEditForm.matCode" 
                  label-field="code"
                  value-field="id"
                  :search-options="searchOptions"
                  :readonly="true"
                  url="/manager/admin/material/getMaterials"
                  :columns="codeColumns"
                  selection="single"
                  @select="codeChanged"
                ></h-select-table>
              </q-field>
              <q-field 
                label="零件名称"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.matName.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-input 
                  @blur="$v.rowAddOrEditForm.matName.$touch"
                  v-model.trim="rowAddOrEditForm.matName"></q-input>
              </q-field>
              <q-field 
                label="零件状态"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.matState.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-select 
                  :options="matStateOptions"
                  @blur="$v.rowAddOrEditForm.matState.$touch"
                  v-model="rowAddOrEditForm.matState"></q-select>
              </q-field>
              <q-field 
                label="所属车型"
                orientation="vertical"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-input v-model.trim="rowAddOrEditForm.carSeriesName"></q-input>
              </q-field>
              <q-field 
                label="单位"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.unitId.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-select 
                  filter
                  :options="unitOptions"
                  @blur="$v.rowAddOrEditForm.unitId.$touch"
                  v-model="rowAddOrEditForm.unitId"></q-select>
              </q-field>
              <q-field 
                label="货币"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.currencyId.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-select 
                  filter
                  :options="currencyOptions"
                  @blur="$v.rowAddOrEditForm.currencyId.$touch"
                  v-model="rowAddOrEditForm.currencyId"></q-select>
              </q-field>
              <q-field 
                label="单车用量"
                orientation="vertical"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-input v-model.trim="rowAddOrEditForm.carQuantity"></q-input>
              </q-field>
              <q-field 
                label="需求数量"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.quantity.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-input 
                  @blur="$v.rowAddOrEditForm.quantity.$touch"
                  v-model.trim="rowAddOrEditForm.quantity"></q-input>
              </q-field>
              <q-field 
                label="报价模板"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.quoteTempId.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-select 
                  filter
                  :options="quoteTempOptions"
                  @blur="$v.rowAddOrEditForm.quoteTempId.$touch"
                  v-model="rowAddOrEditForm.quoteTempId"></q-select>
              </q-field>
              <q-field 
                label="税码"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.taxCode.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-select 
                  filter
                  :options="taxCodeOptions"
                  @blur="$v.rowAddOrEditForm.taxCode.$touch"
                  v-model="rowAddOrEditForm.taxCode"></q-select>
              </q-field>
              <q-field 
                label="计划要货时间（天数）"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.deliveryTime.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-input 
                  @blur="$v.rowAddOrEditForm.deliveryTime.$touch"
                  v-model.trim="rowAddOrEditForm.deliveryTime"></q-input>
              </q-field>
              <q-field 
                label="最小订单数量"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.minOrderQty.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-input 
                  @blur="$v.rowAddOrEditForm.minOrderQty.$touch"
                  v-model.trim="rowAddOrEditForm.minOrderQty"></q-input>
              </q-field>
              <q-field 
                label="模具摊销"
                helper="若选择是，则您须完整填写模具摊销部分"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.isMoldCostShare.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-select 
                  :options="isOptions"
                  @blur="$v.rowAddOrEditForm.isMoldCostShare.$touch"
                  v-model="rowAddOrEditForm.isMoldCostShare"></q-select>
              </q-field>
            </q-card-main>
            <p class="q-mb-none bdl-secondary-3 q-py-xs q-px-sm">内部信息</p>
            <q-card-main class="row gutter-x-md gutter-y-xs">
              <q-field 
                label="SOR编码"
                orientation="vertical"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <h-select-table 
                  :label="rowAddOrEditForm.sorCode"
                  :value="rowAddOrEditForm.sorCode" 
                  label-field="code"
                  value-field="code"
                  :search-options="searchOptions"
                  :readonly="true"
                  url="/manager/sor/main/query"
                  :columns="codeColumns"
                  selection="single"
                  @select="sorCodeChanged"
                ></h-select-table>
              </q-field>
              <q-field 
                label="SOR申请人"
                orientation="vertical"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <h-select-table 
                  :value="rowAddOrEditForm.proposerId" 
                  :label="rowAddOrEditForm.proposerName"
                  label-field="name"
                  value-field="id"
                  :search-options="searchOptions"
                  :readonly="true"
                  url="/manager/user/userData/getUserList"
                  :columns="userColumns"
                  selection="single"
                  @select="proposerChanged"
                ></h-select-table>
              </q-field>
              <q-field 
                label="项目编码"
                orientation="vertical"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-input 
                  v-model.trim="rowAddOrEditForm.projectCode"></q-input>
              </q-field>
              <q-field 
                label="要求定点时间"
                orientation="vertical"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-datetime 
                  type="datetime" 
                  format="YYYY-MM-DD HH-mm"
                  format-model="string"
                  v-model="rowAddOrEditForm.requiredFinishTime"></q-datetime>
              </q-field>
              <q-field 
                label="品类"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.matCategoryCode.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <h-select-tree
                  url="/manager/rfq/main/getSorcingClassifyTree"
                  :value="rowAddOrEditForm.matCategoryCode"
                  :label="rowAddOrEditForm.matCategoryName"
                  value-field="sysCode"
                  label-field="text"
                  no-check-label="若暂无所需品类请勾选此项"
                  @ticked="ticked"
                ></h-select-tree>
              </q-field>
              <q-field 
                label="产品线"
                orientation="vertical"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-input 
                  v-model.trim="rowAddOrEditForm.productLineName"></q-input>
              </q-field>
              <q-field 
                label="目标含税单价"
                orientation="vertical"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-input v-model.trim="rowAddOrEditForm.targetPrice"></q-input>
              </q-field>
              <q-field 
                label="核算价格"
                orientation="vertical"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-input v-model.trim="rowAddOrEditForm.adjustPrice"></q-input>
              </q-field>
            </q-card-main>
            <p v-if="rowAddOrEditForm.isMoldCostShare == 1" class="q-mb-none bdl-secondary-3 q-py-xs q-px-sm">模具摊销</p>
            <q-card-main v-if="rowAddOrEditForm.isMoldCostShare == 1" class="row gutter-x-md gutter-y-xs">
              <q-field 
                label="模具摊销类型"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.shareType.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-select 
                  filter
                  :options="shareTypeOptions"
                  @blur="$v.rowAddOrEditForm.shareType.$touch"
                  v-model="rowAddOrEditForm.shareType"></q-select>
              </q-field>
              <q-field 
                label="摊销时间设置"
                v-if="rowAddOrEditForm.shareType == 2"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.shareQuantity.$error||$v.rowAddOrEditForm.shareUnitId.$error"
                :error-label="$v.rowAddOrEditForm.shareQuantity.$error?'该字段为必填项': '请选择单位'"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <div class="row no-wrap">
                  <q-input 
                    class="col-8" 
                    @blur="$v.rowAddOrEditForm.shareQuantity.$touch"
                    v-model="rowAddOrEditForm.shareQuantity"></q-input>
                  <q-select 
                    filter
                    class="col-4"
                    :options="unitOptions"
                    @blur="$v.rowAddOrEditForm.shareUnitId.$touch"
                    v-model="rowAddOrEditForm.shareUnitId"></q-select>
                </div>
              </q-field>
              <q-field 
                label="摊销数量设置"
                v-if="rowAddOrEditForm.shareType == 3"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.shareQuantity.$error||$v.rowAddOrEditForm.shareUnitId.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <div class="row no-wrap">
                  <q-input 
                    class="col-8" 
                    @blur="$v.rowAddOrEditForm.shareQuantity.$touch"
                    v-model="rowAddOrEditForm.shareQuantity"></q-input>
                  <q-select 
                    filter
                    class="col-4"
                    :options="unitOptions"
                    @blur="$v.rowAddOrEditForm.shareUnitId.$touch"
                    v-model="rowAddOrEditForm.shareUnitId"></q-select>
                </div>
              </q-field>
              <q-field 
                label="付款条款"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.sharePaymentId.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-select 
                  filter
                  :options="payOptions"
                  @blur="$v.rowAddOrEditForm.sharePaymentId.$touch"
                  v-model.trim="rowAddOrEditForm.sharePaymentId"></q-select>
              </q-field>
              <q-field 
                label="付款日期"
                orientation="vertical"
                :error="$v.rowAddOrEditForm.sharePaymentTime.$error"
                error-label="该字段为必填项"
                class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                <q-datetime 
                  type="datetime"
                  format="YYYY-MM-DD HH-mm"
                  format-model="string"
                  @blur="$v.rowAddOrEditForm.sharePaymentTime.$touch"
                  v-model.trim="rowAddOrEditForm.sharePaymentTime"></q-datetime>
              </q-field>
            </q-card-main>
          </q-card>
          <q-toolbar slot="footer" color="white" class="row justify-end">
            <q-btn
              glossy
              :loading="btnLoading"
              color="primary"
              size="sm"
              v-if="detailsAddOrEdit == 1"
              @click="detailsSaveConfirm(1)">{{$t("保存")}}</q-btn>
            <q-btn
              glossy
              :loading="btnLoading"
              color="primary"
              size="sm"
              v-else
              @click="detailsSaveConfirm(2)">{{$t("保存")}}</q-btn>
            <q-btn
              glossy
              color="secondary"
              size="sm"
              class="q-ml-sm"
              @click="detailsAddOrEditModal = false">{{$t("取消")}}</q-btn>
          </q-toolbar>
        </q-modal-layout>
      </q-modal>
      <!-- 附件 新增 or 编辑 -->
      <q-modal no-backdrop-dismiss v-model="fileAddOrEditModal" :content-css="{minWidth: '44vw', minHeight: '400px',borderRadius: '4px'}">
        <q-modal-layout>
          <q-toolbar slot="header" color="white">
            <q-toolbar-title class="text-dark">
              <span>{{ fileAddOrEdit == 1 ? $t("新增") : $t("编辑")  }}</span>
            </q-toolbar-title>
            <q-btn flat @click="fileAddOrEditModal = false">
              <q-icon name="close" color="dark"></q-icon>
            </q-btn>
          </q-toolbar>
          <q-card class="bg-white no-shadow full-width">
            <q-card-main class="row justify-center gutter-x-md gutter-y-xs">
              <q-field 
                v-if="fileAddOrEdit == 1"
                label="附件"
                orientation="vertical"
                :error="$v.fileAddOrEditForm.id.$error"
                error-label="该字段为必填项"
                class="col-lg-10 col-md-10 col-sm-12 col-xs-12">
                <q-uploader 
                  ref="fileUploader"
                  name="files"
                  @uploaded="fileUploaded"
                  :headers="{'Accept': 'application/json;charset=utf-8'}"
                  :url="uploadUrl+'ENQUIRY'" ></q-uploader>
              </q-field>
              <q-field 
                label="说明"
                orientation="vertical"
                class="col-lg-10 col-md-10 col-sm-6 col-xs-12">
                <q-input 
                  type="textarea"
                  rows="4"
                  v-model="fileAddOrEditForm.remark" ></q-input>
              </q-field>
            </q-card-main>
          </q-card>
          <q-toolbar slot="footer" color="white" class="row justify-end">
            <q-btn
              glossy
              :loading="btnLoading"
              color="primary"
              size="sm"
              v-if="fileAddOrEdit == 1"
              @click="fileSaveConfirm(1)">{{$t("保存")}}</q-btn>
            <q-btn
              glossy
              :loading="btnLoading"
              color="primary"
              size="sm"
              v-else
              @click="fileSaveConfirm(2)">{{$t("保存")}}</q-btn>
            <q-btn
              glossy
              color="secondary"
              size="sm"
              class="q-ml-sm"
              @click="fileAddOrEditModal = false">{{$t("取消")}}</q-btn>
          </q-toolbar>
        </q-modal-layout>
      </q-modal>
      <!-- 供应商 新增 or 编辑 -->
      <q-modal no-backdrop-dismiss v-model="supAddOrEditModal" :content-css="{minWidth: '77vw', minHeight: '550px',borderRadius: '4px'}">
        <q-modal-layout>
          <q-toolbar slot="header" color="white">
            <q-toolbar-title class="text-dark">
              <span>{{ supAddOrEdit == 1 ? $t("新增") : $t("编辑")  }}</span>
            </q-toolbar-title>
            <q-btn flat @click="supAddOrEditModal = false">
              <q-icon name="close" color="dark"></q-icon>
            </q-btn>
          </q-toolbar>
          <q-card class="q-px-md q-py-sm bg-white no-shadow full-width">
            <q-card-main class="row justify-between gutter-x-md gutter-y-xs">
              <q-field 
                label="供应商编码"
                orientation="vertical"
                :error="$v.supAddOrEditForm.supplierCode.$error"
                error-label="该字段为必填项"
                class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                <h-select-table 
                  :value="supAddOrEditForm.supplierCode" 
                  :label="supAddOrEditForm.supplierCode" 
                  label-field="code"
                  value-field="code"
                  :search-options="searchOptionsSup"
                  :readonly="true"
                  url="/manager/new/vendor/baseInfoNew/queryVendors"
                  :columns="supCodeColumns"
                  selection="single"
                  @select="supCodeChanged"
                ></h-select-table>
              </q-field>
              <q-field 
                label="供应商名称"
                orientation="vertical"
                class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                <q-input 
                  :readonly="true"
                  v-model.trim="supAddOrEditForm.supplierName"></q-input>
              </q-field>
              <q-field 
                label="供应商阶段"
                orientation="vertical"
                class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                <q-input 
                  :readonly="true"
                  v-model="supAddOrEditForm.supplierStep"></q-input>
              </q-field>
              <q-field 
                label="推荐人"
                orientation="vertical"
                :error="$v.supAddOrEditForm.referrerId.$error"
                error-label="该字段为必填项"
                class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                <h-select-table 
                  :value="supAddOrEditForm.referrerId" 
                  :label="referrerName" 
                  label-field="name"
                  value-field="id"
                  :search-options="searchOptions"
                  :readonly="true"
                  url="/manager/user/userData/getUserList"
                  :columns="userColumns"
                  selection="single"
                  @select="referrerChanged"
                ></h-select-table>
              </q-field>
              <q-field 
                label="说明"
                orientation="vertical"
                class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <q-input 
                  type="textarea"
                  rows="4"
                  v-model="supAddOrEditForm.remark" ></q-input>
              </q-field>
            </q-card-main>
          </q-card>
          <q-toolbar slot="footer" color="white" class="row justify-end">
            <q-btn
              glossy
              :loading="btnLoading"
              color="primary"
              size="sm"
              v-if="supAddOrEdit == 1"
              @click="supSaveConfirm(1)">{{$t("保存")}}</q-btn>
            <q-btn
              glossy
              :loading="btnLoading"
              color="primary"
              size="sm"
              v-else
              @click="supSaveConfirm(2)">{{$t("保存")}}</q-btn>
            <q-btn
              glossy
              color="secondary"
              size="sm"
              class="q-ml-sm"
              @click="supAddOrEditModal = false">{{$t("取消")}}</q-btn>
          </q-toolbar>
        </q-modal-layout>
      </q-modal>
    </div>
    
    <!-- ie-polyfill 、 vue.js and quasar-framework -->
    <script src="../lib/js/quasar.ie.polyfills.umd.min.js"></script>
    <script src="../lib/js/vue.js"></script>
    <script src="../lib/js/quasar.mat.umd.min.js"></script>
    <!-- babel for es6 transform -->
    <!-- <script src="lib/js/babel.min.js"></script> -->
    <!-- vue validate -->
    <script src="../lib/js/vuelidate.min.js"></script>
    <script src="../lib/js/validators.min.js"></script>
    <!-- consts and utils ps: always leave this file first -->
    <script src="../script/consts.js"></script>
    <script src="../script/utils.js"></script>
    <!-- status code -->
    <script src="../script/status.code.js"></script>
    <!-- qs for axios -->
    <script src="../lib/js/qs.min.js"></script>
    <!-- axios for http request -->
    <script src="../lib/js/axios.js"></script>
    <!-- axios.instance must be after axios -->
    <script src="../script/axios.instance2.js"></script>
    <!-- quasar i18n zh-hans -->
    <script src="../lib/lang/zh-hans.js"></script>
    <!-- vue-i18n for application's internationalization -->
    <script src="../lib/js/vue-i18n.js"></script>
    <!-- current page international file -->
    <script src="../lang/sor/rfxPurAdd.js"></script>
    <!-- 本地组件 -->
    <script src="../components/h-select-table.js"></script>
    <script src="../components/h-select-tree.js"></script>

    <script>
			// quasar components use
      Quasar.i18n.set(Quasar.i18n[LANGUGE])
      Vue.prototype.window = window
      Vue.use(window.vuelidate.default)
      var minLength = window.validators.minLength
      var required = window.validators.required
      var requiredIf = window.validators.requiredIf
      var email = window.validators.email
      var helpers = window.validators.helpers
      var mustNumber = function(value) {
        return /^\d+(\.\d+)?$|^$/.test(value) || !helpers.req(value)
      }
			new Vue({
        el: '#q-rfxPurAdd',
        i18n: i18n,
				data: function() {
					return {
            // 通用
            addOrEdit: 1, // 1 新增 2 编辑
            detailsIds: '',
            currentId: '',
            selectedTab: 'tab-1',
            disable: true,
            uploadUrl: baseURL+'/manager/rfq/file/upload/',
            listLoading: false,
            btnLoading: false,
            btnLoadingSearch: false,
            btnLoadingReset: false,
            visible: false,
            // 各种 options
            isSealOptions: [
              {
                label: '是',
                value: 1
              },
              {
                label: '否',
                value: 0
              }
            ],
            typeOptions: [  //询价类型 1: project - 项目 2：price-调价 3：PCN -产品变更 4：ECN-工程变更 5：Supplier 供方变更
              {
                label: '项目',
                value: 1
              },
              {
                label: '调价',
                value: 2
              },
              {
                label: '产品变更',
                value: 3
              },
              {
                label: '工程变更',
                value: 4
              },
              {
                label: '供方变更',
                value: 5
              }
            ],
            purOrgOptions: [],
            purGroupOptions: [],
            isOptions: [
              {
                label: '是',
                value: 1
              },
              {
                label: '否',
                value: 0
              }
            ],
            searchOptions: [
              {
                label: '名称',
                value: 'search-LIKE_name'
              }
            ],
            searchOptionsSup: [
              {
                label: '名称',
                value: 'search-LIKE_supplierName'
              }
            ],
            matStateOptions: [
              {
                label: '新开发',
                value: 1
              },
              {
                label: '借用件',
                value: 2
              },
              {
                label: '改制件',
                value: 3
              }
            ],
            currencyOptions: [], 
            quoteTempOptions: [],
            taxCodeOptions: [],
            unitOptions: [],
            shareTypeOptions: [
              {
                label: '一次性成本摊销',
                value: 1
              },
              {
                label: '基于时间摊销',
                value: 2
              },
              {
                label: '基于数量摊销',
                value: 3
              }
            ],
            payOptions: [],
            // 基本信息
            baseAddOrEditForm: {
              title: null,
              type: null,
              purOrgId: null,
              purGroupId: null,
              purExecutorId: null,
              isSeal: 0,
              isSignUp: 1,
              signUpStartTime: null,
              signUpEndTime: null,
              quoteStartTime: null,
              quoteEndTime: null,
              quoteModifyTimes: 1,
              isTr: 0,
              trFileId: null,
              remark: '',
              isClose: null,
              status: null
            },
            purExecutorName: '', // 执行人名称
            
            // 明细
            detailsAddOrEdit: 1, // 1 新增  2 编辑
            detailsAddOrEditModal: false,
            searchForm: {
              value: '',
              key: 'matName'
            },
            detailsTableData: [],
            total: 0,
            serverPagination: {
              page: 1,
              rowsPerPage: 10,
              rowsNumber: 10
            },
            selected: [],
            rowAddOrEditForm: {
              matId: '',
              matCode: '',
              matName: '',
              matState: '',
              carSeriesName: '',
              carQuantity: '',
              unitId: '',
              currencyId: '',
              quoteTempId: '1',
              quantity: '',
              isMoldCostShare: '',
              taxCode: '',
              minOrderQty: '',
              deliveryTime: '',
              sorCode: '',
              proposerId: '',
              proposerName: '',
              projectCode: '',
              requiredFinishTime: '',
              productLineName: '',
              matCategoryCode: '',
              matCategoryName: '',
              targetPrice: '',
              adjustPrice: '',
              shareType: '',
              shareQuantity: '',
              shareUnitId: '',
              sharePaymentId: '',
              sharePaymentTime: '',
            },
            // 附件
            fileTableData: [],
            totalFile: 0,
            serverPaginationFile: {
              page: 1,
              rowsPerPage: 10,
              rowsNumber: 10
            },
            selectedFile: [],
            fileAddOrEditModal: false,
            fileAddOrEdit: 1,
            fileAddOrEditForm: {
              id: '',
              remark: ''
            },
            // 供应商
            searchFormSup: {
              value: '',
              key: 'supplierName'
            },
            supTableData: [],
            totalSup: 0,
            serverPaginationSup: {
              page: 1,
              rowsPerPage: 10,
              rowsNumber: 10
            },
            selectedSup: [],
            supAddOrEditForm: {
              supplierCode: '',
              supplierName: '',
              supplierStep: '',
              referrerId: '',
              remark: ''
            },
            referrerName: '',
            supAddOrEditModal: false,
            supAddOrEdit: 1,
          }
				},
        validations: {
          baseAddOrEditForm: {
            title: { required: required },
            type: { required: required },
            purOrgId: { required: required },
            purGroupId: { required: required },
            purExecutorId: { required: required },
            isSignUp: { required: required },
            signUpStartTime: { required: requiredIf(function(baseAddOrEditForm) {
              return baseAddOrEditForm.isSignUp == 1
            })},
            signUpEndTime: { required: requiredIf(function(baseAddOrEditForm) {
              return baseAddOrEditForm.isSignUp == 1
            })},
            quoteStartTime: { required: required },
            quoteEndTime: { required: required },
            quoteModifyTimes: { required: required, mustNumber: mustNumber },
            isSeal: { required: required },
            isTr: { required: required },
            trFileId: { required: requiredIf(function(baseAddOrEditForm) {
              return baseAddOrEditForm.isTr == 1
            })}
          },
          rowAddOrEditForm: {
            matName: { required: required },
            matCategoryCode: { required: required },
            matState: { required: required },
            unitId: { required: required },
            quantity: { required: required },
            currencyId: { required: required },
            quoteTempId: { required: required },
            taxCode: { required: required },
            minOrderQty: { required: required },
            deliveryTime: { required: required },
            matCategoryCode: { required: required },
            isMoldCostShare: { required: required },
            shareType: { required: requiredIf(function(rowAddOrEditForm) {
              return rowAddOrEditForm.isMoldCostShare == 1
            })},
            shareQuantity: { required: requiredIf(function(rowAddOrEditForm) {
              return rowAddOrEditForm.shareType == 2 || rowAddOrEditForm.shareType == 3
            })},
            shareUnitId: { required: requiredIf(function(rowAddOrEditForm) {
              return rowAddOrEditForm.shareType == 2 || rowAddOrEditForm.shareType == 3
            })},
            sharePaymentId: { required: requiredIf(function(rowAddOrEditForm) {
              return rowAddOrEditForm.isMoldCostShare == 1
            })},
            sharePaymentTime: { required: requiredIf(function(rowAddOrEditForm) {
              return rowAddOrEditForm.isMoldCostShare == 1
            })},
          },
          fileAddOrEditForm: {
            id: { required: requiredIf(function() {
              return this.fileAddOrEdit == 1
            })},
          },
          supAddOrEditForm: {
            supplierCode: { required: required },
            referrerId: { required: required }
          }
        },
				computed: {
          columns: function() {
            return [
              {
                name: 'action',
                label: '操作',
                align: 'center',
                field: 'action'
              },
              {
                name: 'matName',
                label: '零件名称',
                align: 'center',
                field: 'matName'
              },
              {
                name: 'matCode',
                label: '零件编号',
                align: 'center',
                field: 'matCode'
              },
              {
                name: 'matCategoryName',
                label: '品类',
                align: 'center',
                field: 'matCategoryName'
              },
              {
                name: 'carSeriesName',
                label: '所属车型',
                align: 'center',
                field: 'carSeriesName'
              },
              {
                name: 'quantity',
                label: '数量',
                align: 'center',
                field: 'quantity'
              },
              {
                name: 'unitName',
                label: '价格单位',
                align: 'center',
                field: 'unitName'
              },
              {
                name: 'carQuantity',
                label: '单车用量',
                align: 'center',
                field: 'carQuantity'
              },
              {
                name: 'currencyName',
                label: '币种',
                align: 'center',
                field: 'currencyName'
              },
              {
                name: 'quoteTempName',
                label: '报价模板',
                align: 'center',
                field: 'quoteTempName'
              },
              {
                name: 'targetPrice',
                label: '目标单价',
                align: 'center',
                field: 'targetPrice'
              },
              {
                name: 'adjustPrice',
                label: '核算价格',
                align: 'center',
                field: 'adjustPrice'
              },
              {
                name: 'isMoldCostShare',
                label: '模具摊销',
                align: 'center',
                field: 'isMoldCostShare'
              },
              {
                name: 'sorCode',
                label: '源SOR编码',
                align: 'center',
                field: 'sorCode'
              },
              {
                name: 'projectCode',
                label: '源项目编码',
                align: 'center',
                field: 'projectCode'
              },
              {
                name: 'proposerName',
                label: '申请人',
                align: 'center',
                field: 'proposerName'
              },
              {
                name: 'requiredFinishTime',
                label: '要求定点时间',
                align: 'center',
                field: 'requiredFinishTime'
              },
              {
                name: 'productLineName',
                label: '产品线',
                align: 'center',
                field: 'productLineName'
              },
              {
                name: 'shareType', // 1：一次性成本摊销  2：基于时间摊销 3：基于数量摊销
                label: '摊销类型',
                align: 'center',
                field: 'shareType'
              },
              {
                name: 'shareQuantity',
                label: '摊销数量或时间',
                align: 'center',
                field: 'shareQuantity'
              },
              {
                name: 'sharePaymentTime',
                label: '付款时间',
                align: 'center',
                field: 'sharePaymentTime'
              }
            ]
          },
          codeColumns: function() {
            return [
              {
                name: 'code',
                label: '编码',
                align: 'center',
                field: 'code',
                sortable: true
              },
              {
                name: 'name',
                label: '名称',
                align: 'center',
                field: 'name'
              }
            ]
          },
          pages: function() {
            return Math.ceil(this.total/this.serverPagination.rowsPerPage)
          },
          personColumns: function() {
            return [
              {
                name: 'name',
                label: '名称',
                align: 'center',
                field: 'name'
              },
              {
                name: 'email',
                label: '邮件',
                align: 'center',
                field: 'email'
              }
            ]
          },
          userColumns: function() {
            return [
              {
                name: 'name',
                label: '名称',
                align: 'center',
                field: 'name'
              }
            ]
          },
          fileColumns: function() {
            return [
              {
                name: 'action',
                label: '操作',
                align: 'center',
                field: 'action'
              },
              {
                name: 'fileName',
                label: '文件名称',
                align: 'center',
                field: 'fileName'
              },
              {
                name: 'suffix',
                label: '格式',
                align: 'center',
                field: 'suffix'
              },
              {
                name: 'updateUserName',
                label: '修改人',
                align: 'center',
                field: 'updateUserName'
              },
              {
                name: 'lastUpdateTime',
                label: '修改日期',
                align: 'center',
                field: 'lastUpdateTime'
              },
              {
                name: 'remark',
                label: '说明',
                align: 'center',
                field: 'remark'
              },
            ]
          },
          pagesFile: function() {
            return Math.ceil(this.totalFile/this.serverPaginationFile.rowsPerPage)
          },
          supColumns: function() {
            return [
              {
                name: 'action',
                label: '操作',
                align: 'center',
                field: 'action'
              },
              {
                name: 'supplierCode',
                label: '供应商编码',
                align: 'center',
                field: 'supplierCode'
              },
              {
                name: 'supplierName',
                label: '供应商名称',
                align: 'center',
                field: 'supplierName'
              },
              {
                name: 'supplierStep',
                label: '供应商阶段',
                align: 'center',
                field: 'supplierStep'
              },
              {
                name: 'remark',
                label: '备注',
                align: 'center',
                field: 'remark'
              }
            ]
          },
          pagesSup: function() {
            return Math.ceil(this.totalSup/this.serverPaginationSup.rowsPerPage)
          },
          supCodeColumns: function() {
            return [
              {
                name: 'code',
                label: '编码',
                align: 'center',
                field: 'code',
                sortable: true
              },
              {
                name: 'name',
                label: '名称',
                align: 'center',
                field: 'name'
              }
            ]
          }
        },
        watch: {
          selectedTab: function(selectedTab) {
            if (selectedTab == 'tab-1') {
              this.baseInfoDataGet()
            }
            if (selectedTab == 'tab-2') {
              this.DetailsListGet({ pagination:this.serverPagination })
            }
            if (selectedTab == 'tab-3') {
              this.fileListGet({ pagination:this.serverPaginationFile })
            }
            if (selectedTab == 'tab-4') {
              this.supListGet({ pagination:this.serverPaginationSup })
            }
          },
          'baseAddOrEditForm.isSignUp': function(isSignUp) {
            if (isSignUp == 0) {
              this.baseAddOrEditForm.signUpStartTime = ''
              this.baseAddOrEditForm.signUpEndTime = ''
            }
            this.$v.baseAddOrEditForm.signUpStartTime.$reset()
            this.$v.baseAddOrEditForm.signUpEndTime.$reset()
          },
          'baseAddOrEditForm.isTr': function(isTr) {
            if (isTr == 0) {
              this.baseAddOrEditForm.trFileId = ''
            }
            this.$v.baseAddOrEditForm.trFileId.$reset()
          },
          'rowAddOrEditForm.isMoldCostShare': function(isMoldCostShare) {
            if (isMoldCostShare == 0) {
              this.rowAddOrEditForm.shareType = ''
              this.rowAddOrEditForm.sharePaymentId = ''
              this.rowAddOrEditForm.sharePaymentTime = ''
            }
            this.$v.rowAddOrEditForm.shareType.$reset()
            this.$v.rowAddOrEditForm.sharePaymentId.$reset()
            this.$v.rowAddOrEditForm.sharePaymentTime.$reset()
          },
          'rowAddOrEditForm.shareType': function(shareType) {
            if (shareType == 0) {
              this.rowAddOrEditForm.shareQuantity = ''
              this.rowAddOrEditForm.shareUnitId = ''
            }
            this.$v.rowAddOrEditForm.shareQuantity.$reset()
            this.$v.rowAddOrEditForm.shareUnitId.$reset()
          },
          'serverPagination.rowsPerPage': function(rowsPerPage) {
            this.DetailsListGet({ pagination: this.serverPagination })
          },
          'serverPagination.page': function(page) {
            this.DetailsListGet({ pagination: this.serverPagination })
          },
          'serverPaginationFile.rowsPerPage': function(rowsPerPage) {
            this.fileListGet({ pagination: this.serverPaginationFile })
          },
          'serverPaginationFile.page': function(page) {
            this.fileListGet({ pagination: this.serverPaginationFile })
          },
          'serverPaginationSup.rowsPerPage': function(rowsPerPage) {
            this.supListGet({ pagination: this.serverPaginationSup })
          },
          'serverPaginationSup.page': function(page) {
            this.supListGet({ pagination: this.serverPaginationSup })
          }
        },
        created: function() {
          this.perOrgDataGet()
          this.perGroupDataGet()
          this.currencyDataGet()
          this.taxCodeDataGet()
          this.unitDataGet()
          this.quoteTempDataGet()
          this.payDataGet()
          var args = GetRequest()
          this.addOrEdit = args.addOrEdit
          if (args.ids) {
            this.detailsIds = args.ids
          }
          // 如果是编辑
          if (this.addOrEdit == 2) {
            this.currentId = args.id
            this.disable = false
            this.baseInfoDataGet()
          }
        },
				methods: {
          // 基本信息获取
          baseInfoDataGet: function() {
            this.visible = true
            var that = this
            axios({
              method: 'post',
              url: '/manager/rfq/main/getMainInfo/' + this.currentId,  
            })
            .then(function(data) {
              var data = data.data
              that.baseAddOrEditForm = {
                title: data.title,
                type: data.type,
                purOrgId: data.purOrgId,
                purGroupId: data.purGroupId,
                purExecutorId: data.purExecutorId,
                isSeal: data.isSeal,
                isSignUp: data.isSignUp,
                signUpStartTime: data.signUpStartTime,
                signUpEndTime: data.signUpEndTime,
                quoteStartTime: data.quoteStartTime,
                quoteEndTime: data.quoteEndTime,
                quoteModifyTimes: data.quoteModifyTimes,
                isTr: data.isTr,
                trFileId: data.trFileId,
                remark: data.remark,
                isClose: data.isClose,
                status: data.status
              }
              that.purExecutorName = data.purExecutorName
              setTimeout(function() {
                that.visible = false
              }, 500);
            })
            .catch(function(err) {
              console.log(err)
            })
          },
          personChanged: function(newV) {
            this.baseAddOrEditForm.purExecutorId = newV[0].id
          },
          trUploaded: function(file, xhr) {
            var res = JSON.parse(xhr.response)
            if (res.success) {
              this.$q.notify({
                message: '上传成功',
                type: 'positive',
                icon: 'done',
                timeout: 1000,
                position: 'top-right'
              })
              this.baseAddOrEditForm.trFileId = res.data
            } else {
              this.$q.notify({
                message: res.msg,
                type: 'negative',
                icon: 'error_outline',
                timeout: 2000,
                position: 'top-right'
              })
            }
          },
          // 基本信息保存
          baseInfoSave: function() {
            var that = this
            this.$v.baseAddOrEditForm.$touch()
            if (!this.$v.baseAddOrEditForm.$error) {
              this.btnLoading = true
              this.visible = true
              if (this.addOrEdit == 2) {
                this.baseAddOrEditForm.headerId = this.currentId
              }
              this.baseAddOrEditForm.sorItemIds = this.detailsIds
              this.baseAddOrEditForm.signUpStartTime = timeUtil(this.baseAddOrEditForm.signUpStartTime)
              this.baseAddOrEditForm.signUpEndTime = timeUtil(this.baseAddOrEditForm.signUpEndTime)
              this.baseAddOrEditForm.quoteStartTime = timeUtil(this.baseAddOrEditForm.quoteStartTime)
              this.baseAddOrEditForm.quoteEndTime = timeUtil(this.baseAddOrEditForm.quoteEndTime)
              axios({
                method: 'post',
                url: '/manager/rfq/main/save',
                data: this.baseAddOrEditForm
              })
              .then(function(data) {
                if (data.success) {
                  that.$q.notify({
                    message: '操作成功',
                    type: 'positive',
                    icon: 'done',
                    timeout: 1000,
                    position: 'top-right'
                  })
                  // 新增主信息成功  才能放开其它tab
                  // that.currentId = data.data
                  // that.disable = false
                  if (that.addOrEdit == 1) {
                    setTimeout(function() {
                      window.location.href = "./rfxPurAdd.html?addOrEdit=2&id=" + data.data
                    }, 1000)
                  }
                } else {
                  that.$q.notify({
                    message: data.msg,
                    type: 'negative',
                    icon: 'error_outline',
                    timeout: 2000,
                    position: 'top-right'
                  })
                }
                that.btnLoading = false
                setTimeout(function() {
                  that.visible = false
                }, 500)
                that.baseInfoDataGet()
              })
              .catch(function(err) {
                console.log(err)
              })
            }
          },
          // 明细列表数据 获取
          DetailsListGet: function(arg) {
            var that = this 
            this.listLoading = true
            this.visible = true
            this.serverPagination = arg.pagination
            axios({
              method: 'post',
              url: '/manager/rfq/item/query',
              data: {
                page: this.serverPagination.page,
                rows: this.serverPagination.rowsPerPage,
                sort: this.serverPagination.sortBy,
                order: this.serverPagination.descending == true? 'desc' : (this.serverPagination.descending == false? 'asc' : null),
                search_LIKE_matName: this.searchForm.key == 'matName'? this.searchForm.value: '',
                search_LIKE_matCode: this.searchForm.key == 'matCode'? this.searchForm.value: '',
                search_EQ_headerId: this.currentId
              }
            })
            .then(function(data) {
              that.detailsTableData = data.rows
              that.total = data.total
              that.listLoading = false
              setTimeout(function() {
                that.visible = false
              }, 500)
              that.btnLoadingSearch = false
              that.btnLoadingReset = false
            })
            .catch(function(err) {
              console.log(err)
            })
          },
          // 明细 查询
          searchDetails: function() {
            this.btnLoadingSearch = true
            this.DetailsListGet({
              pagination: this.serverPagination
            })
          },
          resetDetails: function() {
            this.btnLoadingReset = true
            this.searchForm = {  
              value: '',
              key: 'matName'
            }
            this.DetailsListGet({
              pagination: this.serverPagination
            })
          },
          // 物料编码 改变
          codeChanged: function(newV) {
            this.rowAddOrEditForm.matId = newV[0].id
            this.rowAddOrEditForm.matCode = newV[0].code
            this.rowAddOrEditForm.matName = newV[0].name
            this.rowAddOrEditForm.matState = newV[0].materialStatus
            this.rowAddOrEditForm.unitId = newV[0].purchaseUnit
          },
          sorCodeChanged: function(newV) {
            this.rowAddOrEditForm.sorCode = newV[0].code
            this.rowAddOrEditForm.proposerId = newV[0].proposerId
            this.rowAddOrEditForm.proposerName = newV[0].proposerName
            this.rowAddOrEditForm.projectCode = newV[0].projectCode
            this.rowAddOrEditForm.requiredFinishTime = newV[0].requiredFinishTime
          },
          proposerChanged: function(newV) {
            this.rowAddOrEditForm.proposerId = newV[0].id
          },
          ticked: function(newV) {
            this.rowAddOrEditForm.matCategoryCode = newV
          },
          detailsModalOpen: function(type, row) {
            this.detailsAddOrEdit = type
            this.rowAddOrEditForm = {
              matId: '',
              matCode: '',
              matName: '',
              matState: '',
              carSeriesName: '',
              carQuantity: '',
              unitId: '',
              currencyId: '',
              quoteTempId: '1',
              quantity: '',
              isMoldCostShare: '',
              taxCode: '',
              minOrderQty: '',
              deliveryTime: '',
              sorCode: '',
              proposerId: '',
              proposerName: '',
              projectCode: '',
              requiredFinishTime: '',
              productLineName: '',
              matCategoryCode: '',
              matCategoryName: '',
              targetPrice: '',
              adjustPrice: '',
              shareType: '',
              shareQuantity: '',
              shareUnitId: '',
              sharePaymentId: '',
              sharePaymentTime: '',
            }
            if (type == 2) {
              this.rowAddOrEditForm = {
                id: row.id,
                itemNo: row.itemNo,
                matId: row.matId,
                matCode: row.matCode,
                matName: row.matName,
                matState: row.matState,
                carSeriesName: row.carSeriesName,
                carQuantity: row.carQuantity,
                unitId: row.unitId,
                currencyId: row.currencyId,
                quoteTempId: row.quoteTempId,
                quantity: row.quantity,
                isMoldCostShare: row.isMoldCostShare,
                taxCode: row.taxCode,
                minOrderQty: row.minOrderQty,
                deliveryTime: row.deliveryTime,
                sorCode: row.sorCode,
                proposerId: row.proposerId,
                proposerName: row.proposerName,
                projectCode: row.projectCode,
                requiredFinishTime: row.requiredFinishTime,
                productLineName: row.productLineName,
                matCategoryCode: row.matCategoryCode,
                matCategoryName: row.matCategoryName,
                targetPrice: row.targetPrice,
                adjustPrice: row.adjustPrice,
                shareType: row.shareType,
                shareQuantity: row.shareQuantity,
                shareUnitId: row.shareUnitId,
                sharePaymentId: row.sharePaymentId,
                sharePaymentTime: row.sharePaymentTime,
              }
            }
            this.rowAddOrEditForm.headerId = this.currentId
            this.$v.rowAddOrEditForm.$reset()
            this.detailsAddOrEditModal = true
          },
          // 明细保存
          detailsSaveConfirm: function(type) {
            this.$v.rowAddOrEditForm.$touch()
            if (!this.$v.rowAddOrEditForm.$error) {
              var that = this
              this.btnLoading = true
              this.rowAddOrEditForm.sharePaymentTime = timeUtil(this.rowAddOrEditForm.sharePaymentTime)
              this.rowAddOrEditForm.requiredFinishTime = timeUtil(this.rowAddOrEditForm.requiredFinishTime)
              axios({
                method: 'post',
                url: '/manager/rfq/item/save',
                data: this.rowAddOrEditForm
              })
              .then(function(data) {
                if (data.success) {
                  that.$q.notify({
                    message: '操作成功',
                    type: 'positive',
                    icon: 'done',
                    timeout: 1000,
                    position: 'top-right'
                  })
                  that.detailsAddOrEditModal = false
                  that.DetailsListGet({ pagination: that.serverPagination })
                } else {
                  that.$q.notify({
                    message: data.msg,
                    type: 'negative',
                    icon: 'error_outline',
                    timeout: 1000,
                    position: 'top-right'
                  })
                }
                that.btnLoading = false
              })
              .catch(function(err) {
                console.log(err)
              })
            }
          },
          // 明细 删除
          detailsDel: function() {
            var that = this
            if (this.selected.length > 0) {
              this.$q.dialog({
                title: '确认',
                message: '确认要删除选中的'+ this.selected.length + '条数据吗？',
                ok: {
                  label: '确认',
                  flat: true
                },
                cancel: {
                  label: '取消',
                  flat: true
                }
              })
              .then(function() {
                var idSelected = []
                that.selected.forEach(function(e) {
                  idSelected.push(e.id)
                })
                axios({
                  method: 'post',
                  url: '/manager/rfq/item/delete',
                  data: {
                    ids: idSelected.join(',')
                  }
                })
                .then(function(data) {
                  if (data.success) {
                    that.$q.notify({
                      message: '操作成功',
                      type: 'positive',
                      icon: 'done',
                      timeout: 1000,
                      position: 'top-right'
                    })
                  } else {
                    that.$q.notify({
                      message: data.msg,
                      type: 'negative',
                      icon: 'error_outline',
                      timeout: 1000,
                      position: 'top-right'
                    })
                  }
                  that.selected = []
                  that.DetailsListGet({ pagination: that.serverPagination })
                })
                .catch(function(err) {
                  console.log(err)
                })
              })
              .catch(function() {
                // 选择"Cancel"或作了关闭操作
              })
            } else {
              this.$q.notify({
                message: '请先勾选，再执行该操作！',
                type: 'warning',
                icon: 'warning',
                position: 'top-right'
              })
            }
          },
          // 附件
          fileListGet: function(arg) {
            var that = this 
            this.listLoading = true
            this.visible = true
            this.serverPaginationFile = arg.pagination
            axios({
              method: 'post',
              url: '/manager/rfq/file/query',
              data: {
                page: this.serverPaginationFile.page,
                rows: this.serverPaginationFile.rowsPerPage,
                sort: this.serverPaginationFile.sortBy,
                order: this.serverPaginationFile.descending == true? 'desc' : (this.serverPaginationFile.descending == false? 'asc' : null),
                search_EQ_busId: this.currentId
              }
            })
            .then(function(data) {
              that.fileTableData = data.rows
              that.totalFile = data.total
              that.listLoading = false
              setTimeout(function() {
                that.visible = false
              }, 500)
            })
            .catch(function(err) {
              console.log(err)
            })
          },
          // 新增 编辑
          fileModalOpen: function(type, row) {
            this.fileAddOrEdit = type
            if (type == 1) {
              this.fileAddOrEditForm = {
                id: '',
                remark: '',
              }
              this.$refs['fileUploader'].reset()
            }
            if (type == 2) {
              this.fileAddOrEditForm = {
                id: row.id,
                remark: row.remark
              }
            }
            this.fileAddOrEditForm.busId = this.currentId
            this.$v.fileAddOrEditForm.$reset()
            this.fileAddOrEditModal = true
          },
          fileUploaded: function(file, xhr) {
            var res = JSON.parse(xhr.response)
            if (res.success) {
              this.$q.notify({
                message: '上传成功',
                type: 'positive',
                icon: 'done',
                timeout: 1000,
                position: 'top-right'
              })
              this.fileAddOrEditForm.id = res.data
            } else {
              this.$q.notify({
                message: res.msg,
                type: 'negative',
                icon: 'error_outline',
                timeout: 2000,
                position: 'top-right'
              })
            }
          },
          fileSaveConfirm: function() {
            this.$v.fileAddOrEditForm.$touch()
            if (!this.$v.fileAddOrEditForm.$error) {
              console.log(this.fileAddOrEditForm, '进来了！！！');
              var that = this
              this.btnLoading = true
              axios({
                method: 'post',
                url: '/manager/rfq/file/saveEnquiryFile',
                data: this.fileAddOrEditForm
              })
              .then(function(data) {
                if (data.success) {
                  that.$q.notify({
                    message: '操作成功',
                    type: 'positive',
                    icon: 'done',
                    timeout: 1000,
                    position: 'top-right'
                  })
                  that.fileAddOrEditModal = false
                  that.fileListGet({ pagination: that.serverPaginationFile })
                } else {
                  that.$q.notify({
                    message: data.msg,
                    type: 'negative',
                    icon: 'error_outline',
                    timeout: 1000,
                    position: 'top-right'
                  })
                }
                that.btnLoading = false
              })
              .catch(function(err) {
                console.log(err)
              })
            }
          },
          fileDel: function() {
            var that = this
            if (this.selectedFile.length > 0) {
              this.$q.dialog({
                title: '确认',
                message: '确认要删除选中的'+ this.selectedFile.length + '条数据吗？',
                ok: {
                  label: '确认',
                  flat: true
                },
                cancel: {
                  label: '取消',
                  flat: true
                }
              })
              .then(function() {
                var idSelected = []
                that.selectedFile.forEach(function(e) {
                  idSelected.push(e.id)
                })
                axios({
                  method: 'post',
                  url: '/manager/rfq/file/delete',
                  data: {
                    ids: idSelected.join(',')
                  }
                })
                .then(function(data) {
                  if (data.success) {
                    that.$q.notify({
                      message: '操作成功',
                      type: 'positive',
                      icon: 'done',
                      timeout: 1000,
                      position: 'top-right'
                    })
                  } else {
                    that.$q.notify({
                      message: data.msg,
                      type: 'negative',
                      icon: 'error_outline',
                      timeout: 1000,
                      position: 'top-right'
                    })
                  }
                  that.selectedFile = []
                  that.fileListGet({ pagination: that.serverPaginationFile })
                })
                .catch(function(err) {
                  console.log(err)
                })
              })
              .catch(function() {
                // 选择"Cancel"或作了关闭操作
              })
            } else {
              this.$q.notify({
                message: '请先勾选，再执行该操作！',
                type: 'warning',
                icon: 'warning',
                position: 'top-right'
              })
            }
          },
          // 供应商
          // 供应商 获取
          supListGet: function(arg) {
            var that = this 
            this.listLoading = true
            this.visible = true
            this.serverPaginationSup = arg.pagination
            axios({
              method: 'post',
              url: '/manager/rfq/supplier/query',
              data: {
                page: this.serverPaginationSup.page,
                rows: this.serverPaginationSup.rowsPerPage,
                sort: this.serverPaginationSup.sortBy,
                order: this.serverPaginationSup.descending == true? 'desc' : (this.serverPaginationSup.descending == false? 'asc' : null),
                search_LIKE_supplierCode: this.searchFormSup.key == 'supplierCode'? this.searchFormSup.value: '',
                search_LIKE_supplierName: this.searchFormSup.key == 'supplierName'? this.searchFormSup.value: '',
                search_EQ_headerId: this.currentId
              }
            })
            .then(function(data) {
              that.supTableData = data.rows
              that.totalSup = data.total
              that.listLoading = false
              setTimeout(function() {
                that.visible = false
              }, 500)
              that.btnLoadingSearch = false
              that.btnLoadingReset = false
            })
            .catch(function(err) {
              console.log(err)
            })
          },
          // psa查询
          psaSearch: function() {
            
          },
          // 新增
          supModalOpen: function(type, row) {
            this.supAddOrEdit = type
            if (type == 1) {
              this.supAddOrEditForm = {
                supplierCode: '',
                supplierName: '',
                supplierStep: '',
                referrerId: '',
                remark: ''
              }
              this.referrerName = ''
            }
            if (type == 2) {
              this.supAddOrEditForm = {
                id: row.id,
                supplierCode: row.supplierCode,
                supplierName: row.supplierName,
                supplierStep: row.supplierStep,
                referrerId: row.referrerId,
                remark: row.remark
              }
              this.referrerName = row.referrerName
            }
            this.supAddOrEditForm.headerId = this.currentId
            this.$v.supAddOrEditForm.$reset()
            this.supAddOrEditModal = true
          },
          supCodeChanged: function(newV) {
            this.supAddOrEditForm.supplierCode = newV[0].code
            this.supAddOrEditForm.supplierName = newV[0].name
            this.supAddOrEditForm.supplierStep = newV[0].stageNewEntity.name
          },
          referrerChanged: function(newV) {
            this.supAddOrEditForm.referrerId = newV[0].id
            this.referrerName = newV[0].name
          },
          supSaveConfirm: function() {
            this.$v.supAddOrEditForm.$touch()
            if (!this.$v.supAddOrEditForm.$error) {
              var that = this
              this.btnLoading = true
              axios({
                method: 'post',
                url: '/manager/rfq/supplier/save',
                data: this.supAddOrEditForm
              })
              .then(function(data) {
                if (data.success) {
                  that.$q.notify({
                    message: '操作成功',
                    type: 'positive',
                    icon: 'done',
                    timeout: 1000,
                    position: 'top-right'
                  })
                } else {
                  that.$q.notify({
                    message: data.msg,
                    type: 'negative',
                    icon: 'error_outline',
                    timeout: 1000,
                    position: 'top-right'
                  })
                }
                that.btnLoading = false
                that.supAddOrEditModal = false
                that.supListGet({ pagination: that.serverPaginationSup })
            })
              .catch(function(err) {
                console.log(err)
              })
            }
          },
          // 查询
          searchSup: function()  {
            this.btnLoadingSearch = true
            this.supListGet({
              pagination: this.serverPaginationSup
            })
          },
          resetSup: function()  {
            this.btnLoadingReset = true
            this.searchFormSup = {  
              value: '',
              key: 'supplierName'
            }
            this.supListGet({
              pagination: this.serverPaginationSup
            })
          },
          supDel: function() {
            var that = this
            if (this.selectedSup.length > 0) {
              this.$q.dialog({
                title: '确认',
                message: '确认要删除选中的'+ this.selectedSup.length + '条数据吗？',
                ok: {
                  label: '确认',
                  flat: true
                },
                cancel: {
                  label: '取消',
                  flat: true
                }
              })
              .then(function() {
                var idSelected = []
                that.selectedSup.forEach(function(e) {
                  idSelected.push(e.id)
                })
                axios({
                  method: 'post',
                  url: '/manager/rfq/supplier/delete',
                  data: {
                    ids: idSelected.join(',')
                  }
                })
                .then(function(data) {
                  if (data.success) {
                    that.$q.notify({
                      message: '操作成功',
                      type: 'positive',
                      icon: 'done',
                      timeout: 1000,
                      position: 'top-right'
                    })
                  } else {
                    that.$q.notify({
                      message: data.msg,
                      type: 'negative',
                      icon: 'error_outline',
                      timeout: 1000,
                      position: 'top-right'
                    })
                  }
                  that.selectedSup = []
                  that.supListGet({ pagination: that.serverPaginationSup })
                })
                .catch(function(err) {
                  console.log(err)
                })
              })
              .catch(function() {
                // 选择"Cancel"或作了关闭操作
              })
            } else {
              this.$q.notify({
                message: '请先勾选，再执行该操作！',
                type: 'warning',
                icon: 'warning',
                position: 'top-right'
              })
            }
          },
          // 激活
          activate: function() {
            var that = this
            this.$q.dialog({
              title: '确认',
              message: '执行激活操作，同时您可以选择是否发布正式询价',
              ok: {
                label: '确认',
                flat: true
              },
              cancel: {
                label: '取消',
                flat: true
              },
              options: {
                type: 'radio', // 或者'checkbox' / 'toggle'
                model: 0, // 使用数组，当checkbox/toggle时! (like '[]')
                items: [
                  {label: '普通询价', value: 0 },
                  {label: '正式询价', value: 1 }
                ]
              }
            })
            .then(function(data) {
              axios({
                method: 'post',
                url: '/manager/rfq/main/active/' + data,
                data: {
                  ids: that.currentId
                }
              })
              .then(function(data) {
                if (data.success) {
                  that.$q.notify({
                    message: '操作成功',
                    type: 'positive',
                    icon: 'done',
                    timeout: 1000,
                    position: 'top-right'
                  })
                  setTimeout(function() {
                    window.location.href = './rfxPurList.html?tab=tab-2'
                  }, 500)
                } else {
                  that.$q.notify({
                    message: data.msg,
                    type: 'negative',
                    icon: 'error_outline',
                    timeout: 1000,
                    position: 'top-right'
                  })
                }
              })
              .catch(function(err) {
                console.log(err)
              })
            })
            .catch(function() {
              // 选择"Cancel"或作了关闭操作
            })
          },
          // 各种数据的获取
          // 获取货币数据
          currencyDataGet: function() {
            var that = this
            axios({
              method: 'post',
              url: '/manager/basedata/frameAgreement/getCurrencyList'
            })
            .then(function(data) {
              var arr = []
              data.forEach(function(item) {
                var obj = {}
                obj.label = item.currencyName
                obj.value = item.id
                arr.push(obj)
              })
              that.currencyOptions = arr
            })
            .catch(function(err) {
              console.log(err)
            })
          },
          // 采购组织 获取
          perOrgDataGet: function() {
            var that = this
            axios({
              method: 'post',
              url: '/manager/rfq/main/getPurOrgList',
            })
            .then(function(data) {
              var a = []
              data.forEach(function(e) {
                var o = {}
                o.label = e.name
                o.value = e.id
                a.push(o)
              })
              that.purOrgOptions = a
            })
            .catch(function(err) {
              console.log(err)
            })
          },
          // 采购组 获取
          perGroupDataGet: function() {
            var that = this
            axios({
              method: 'post',
              url: '/manager/basedata/frameAgreement/getGroupList',
            })
            .then(function(data) {
              var a = []
              data.forEach(function(e) {
                var o = {}
                o.label = e.groupName
                o.value = e.id
                a.push(o)
              })
              that.purGroupOptions = a
            })
            .catch(function(err) {
              console.log(err)
            })
          },
          // 税码 获取
          taxCodeDataGet: function() {
            var that = this
            axios({
              method: 'post',
              url: '/manager/basedata/frameAgreement/getTaxList',
            })
            .then(function(data) {
              var a = []
              data.forEach(function(e) {
                var o = {}
                o.label = e.taxName
                o.value = e.taxCode
                a.push(o)
              })
              that.taxCodeOptions = a
            })
            .catch(function(err) {
              console.log(err)
            })
          },
          // 单位 获取
          unitDataGet: function() {
            var that = this
            axios({
              method: 'post',
              url: '/manager/basedata/frameAgreement/getUnitList',
            })
            .then(function(data) {
              var a = []
              data.forEach(function(e) {
                var o = {}
                o.label = e.unitName
                o.value = e.id
                a.push(o)
              })
              that.unitOptions = a
            })
            .catch(function(err) {
              console.log(err)
            })
          },
          // 报价模板 获取
          quoteTempDataGet: function() {
            var that = this
            axios({
              method: 'post',
              url: '/manager/rfq/template/getQuoteTemps',
            })
            .then(function(data) {
              var a = []
              data.forEach(function(e) {
                var o = {}
                o.label = e.name
                o.value = e.id
                a.push(o)
              })
              that.quoteTempOptions = a
            })
            .catch(function(err) {
              console.log(err)
            })
          },
          // 付款条件 获取
          payDataGet: function() {
            var that = this
            axios({
              method: 'post',
              url: '/manager/common/dict/findByDictIdAndAbolished/1',
            })
            .then(function(data) {
              var a = []
              data.forEach(function(e) {
                var o = {}
                o.label = e.name
                o.value = e.id
                a.push(o)
              })
              that.payOptions = a
            })
            .catch(function(err) {
              console.log(err)
            })
          },
				}
			})
    </script>
  </body>
</html>